#include <iostream>
#include <string>

using namespace std;

void readString(string& str) {
    str = "";
    char c;

    scanf("%c",&c);
    while (c != '\n' && c != EOF) {
        str += c;
        scanf("%c",&c);
    }
}

int getSubStringIndex(const string& str, const string& subStr){
    int subLen = subStr.size();
 
    int* p = new int[subLen];
    p[0] = 0;
    
    int k = 0;
    for (int i = 1; i < subLen; ++i){
       while (k > 0 && subStr[i] != subStr[k]) k = p[k - 1];
         
       if (subStr[i] == subStr[k]) k++;
       p[i] = k;
    }
    
    k = 0;
    for (int i = 0; i < str.size(); ++i){
        while (k > 0 && subStr[k] != str[i]) k = p[k - 1];
         
        if (subStr[k] == str[i]) k++;
        if (k == subLen) {
            delete[] p;
            return i - subLen + 1;
        }
    }
    
    delete[] p;
    return -1;
}


int main() {
    string input, subString;

    readString(input);
    readString(subString);

    while (subString != "") {
        if (input.length() < subString.length()) cout<<"NO"<<endl;
        else {
            int n = -1;
            if ((n = getSubStringIndex(input, subString)) != -1) cout<<n<<endl;
            else cout<<"NO"<<endl;
        }

        readString(subString);
    }

    return 0;
}

